package com.inspur.gs.sbssdl.sbwhgl.sbwhby.sbwhby.front.newsbbyjh_frm.voactions;

import java.util.*;

/**
 * 保养计划模板配置类
 * 定义不同设备类级（A/B/C1/C2/T）的预设保养周期模式
 */
public class MaintenancePlanTemplateConfig {

    // 保养模板：类级 -> 模板列表
    private static final Map<String, List<MaintenancePattern>> TEMPLATES = new HashMap<>();

    static {
        // A类：3种模式，每3个月轮换 (1保,2保,1保,2保)
        TEMPLATES.put("A", Arrays.asList(
                new MaintenancePattern(Arrays.asList(1, 4, 7, 10), Arrays.asList("1", "2", "1", "2")),
                new MaintenancePattern(Arrays.asList(2, 5, 8, 11), Arrays.asList("1", "2", "1", "2")),
                new MaintenancePattern(Arrays.asList(3, 6, 9, 12), Arrays.asList("1", "2", "1", "2"))
        ));

        // B类：4种模式，每4个月 (1保,2保,1保)
        TEMPLATES.put("B", Arrays.asList(
                new MaintenancePattern(Arrays.asList(1, 5, 9), Arrays.asList("1", "2", "1")),
                new MaintenancePattern(Arrays.asList(2, 6, 10), Arrays.asList("1", "2", "1")),
                new MaintenancePattern(Arrays.asList(3, 7, 11), Arrays.asList("1", "2", "1")),
                new MaintenancePattern(Arrays.asList(4, 8, 12), Arrays.asList("1", "2", "1"))
        ));

        // C1类：4种模式，每4个月一保
        TEMPLATES.put("C1", Arrays.asList(
                new MaintenancePattern(Arrays.asList(1, 5, 9), Arrays.asList("1", "1", "1")),
                new MaintenancePattern(Arrays.asList(2, 6, 10), Arrays.asList("1", "1", "1")),
                new MaintenancePattern(Arrays.asList(3, 7, 11), Arrays.asList("1", "1", "1")),
                new MaintenancePattern(Arrays.asList(4, 8, 12), Arrays.asList("1", "1", "1"))
        ));

        // T类：6种模式，每6个月一保
        TEMPLATES.put("T", Arrays.asList(
                new MaintenancePattern(Arrays.asList(1, 7), Arrays.asList("1", "1")),
                new MaintenancePattern(Arrays.asList(2, 8), Arrays.asList("1", "1")),
                new MaintenancePattern(Arrays.asList(3, 9), Arrays.asList("1", "1")),
                new MaintenancePattern(Arrays.asList(4, 10), Arrays.asList("1", "1")),
                new MaintenancePattern(Arrays.asList(5, 11), Arrays.asList("1", "1")),
                new MaintenancePattern(Arrays.asList(6, 12), Arrays.asList("1", "1"))
        ));

        // C2类：无需保养
        TEMPLATES.put("C2", Collections.emptyList());
    }

    /**
     * 获取指定类级的所有保养模板
     * @param deviceClass 设备类级，如 "A", "B", "C1", "T"
     * @return 模板列表，若无匹配则返回空列表
     */
    public static List<MaintenancePattern> getTemplates(String deviceClass) {
        List<MaintenancePattern> templates = TEMPLATES.get(deviceClass);
        return templates != null ? new ArrayList<>(templates) : Collections.emptyList();
    }

    /**
     * 获取所有类级
     */
    public static Set<String> getAllClasses() {
        return new HashSet<>(TEMPLATES.keySet());
    }

    /**
     * 判断某类级是否需要保养
     */
    public static boolean needsMaintenance(String deviceClass) {
        return !"C2".equals(deviceClass) && TEMPLATES.containsKey(deviceClass);
    }
}
